//build：20240315
//Control Styles: Each control can be bound to a style object, allowing you to set multiple styles.
import utils from "./uiUtils.js"

let style = {}
style.build = function () {
    let comp = {}
    comp.obj = new utils.GG.NativeStyle()
    comp.obj.lvStyleInit()
    /**
     * Set the left, right, top, and bottom paddings to the same value.
     * @param {number} pad Margin value
     */
    comp.padAll = function (pad) {
        this.obj.lvStyleSetPadAll(pad)
    }
    /**
     * Set the right inner margin to a single value.
     * @param {number} pad Margin value
     */
    comp.padRight = function (pad) {
        this.obj.lvStyleSetPadRight(pad)
    }
    /**
     * Set the left inner margin to a single value.
     * @param {number} pad Margin value
     */
    comp.padLeft = function (pad) {
        this.obj.lvStyleSetPadLeft(pad)
    }
    /**
     * Set all top and inner margins to a single value.
     * @param {number} pad Margin value
     */
    comp.padTop = function (pad) {
        this.obj.lvStyleSetPadTop(pad)
    }
    /**
     * Set all bottom paddings to a single value.
     * @param {number} pad Margin value
     */
    comp.padBottom = function (pad) {
        this.obj.lvStyleSetPadBottom(pad)
    }
    /**
     * Set the margins between all columns to a single value.
     * @param {number} pad Margin value
     */
    comp.padColumn = function (pad) {
        this.obj.lvStyleSetPadColumn(pad)
    }
    /**
     * Set the margins between rows to a single value.
     * @param {number} pad Margin value
     */
    comp.padRow = function (pad) {
        this.obj.lvStyleSetPadRow(pad)
    }
    /**
     * Set border width
     * @param {number} w 
     */
    comp.borderWidth = function (w) {
        this.obj.lvStyleSetBorderWidth(w)
    }
    /**
     * Set corner radius
     * @param {number} r 
     */
    comp.radius = function (r) {
        this.obj.lvStyleSetRadius(r)
    }
    /**
     * Set the background transparency; the value ranges from 0 to 100, with lower values ​​being better.
     * @param {number} opa It must be 0-100
     */
    comp.bgOpa = function (opa) {
        this.obj.lvStyleSetBgOpa(utils.OPA_MAPPING(opa))
    }
    /**
     * Set the transparency level; the value ranges from 0 to 100, with lower values ​​being better.
     * @param {number} opa It must be 0-100
     */
    comp.opa = function (opa) {
        this.obj.lvStyleSetOpa(utils.OPA_MAPPING(opa))
    }
    /**
     * Set background color
     * @param {any} color Supports numeric types: e.g., 0x34ffaa; and string types (starting with #), e.g., '#34ffaa'.
     */
    comp.bgColor = function (color) {
        this.obj.lvStyleSetBgColor(utils.colorParse(color))
    }
    /**
     * Set text color
     * @param {any} color  Supports numeric types: e.g., 0x34ffaa; and string types (starting with #), e.g., '#34ffaa'.
     */
    comp.textColor = function (color) {
        this.obj.lvStyleSetTextColor(utils.colorParse(color))
    }
    /**
     * Set text alignment
     * @param {number} type  See utils.TEXT_ALIGN
     */
    comp.textAlign = function (type) {
        this.obj.lvStyleSetTextAlign(type)
    }
    /**
     * Set text font
     * @param {object} font The object returned by build in font.js
     */
    comp.textFont = function (font) {
        if (!font || !font.obj) {
            throw new Error("style.textFont: 'font' parameter should not be null")
        }
        this.obj.lvStyleSetTextFont(font.obj)
    }
    /**
     * Set gradient colors
     * @param {number} color Gradient colors, for example: 0xffffff
     */
    comp.bgGradColor = function (color) {
        this.obj.lvStyleSetBgGradColor(color)
    }
    /**
     * Set gradient direction
     * @param {number} dir Currently, only horizontal and vertical directions are supported.
     */
    comp.bgGradDir = function (dir) {
        this.obj.lvStyleSetBgGradDir(dir)
    }
    /**
     * The background color ends at position (0-255).
     * @param {number} value Distance, calculated from the left end.
     */
    comp.bgMainStop = function (value) {
        this.obj.lvStyleSetBgMainStop(value)
    }
    /**
     * The distance of the gradient color (0-255)
     * @param {number} value Distance is calculated starting from the end of the background color.
     */
    comp.bgGradStop = function (value) {
        this.obj.lvStyleSetBgGradStop(value)
    }
    return comp;
}

export default style;